# Maintainer: Philipp Smirnov https://github.com/sad-poet

_realname=lal-refactor
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=25.0.0
pkgrel=2
pkgdesc="Source code refactoring tools for the Ada programming language, leveraging the power of Libadalang (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url="https://github.com/AdaCore/lal-refactor"
msys2_references=(
  'aur: lal-refactor'
)
license=("spdx:Apache-2.0 WITH LLVM-exception")
depends=(
  "${MINGW_PACKAGE_PREFIX}-gcc-ada"
  "${MINGW_PACKAGE_PREFIX}-gcc-libs"
  "${MINGW_PACKAGE_PREFIX}-gmp"
  "${MINGW_PACKAGE_PREFIX}-gnatcoll-core"
  "${MINGW_PACKAGE_PREFIX}-gnatcoll-gmp"
  "${MINGW_PACKAGE_PREFIX}-gpr"
  "${MINGW_PACKAGE_PREFIX}-langkit_support"
  "${MINGW_PACKAGE_PREFIX}-libadalang"
  "${MINGW_PACKAGE_PREFIX}-libadalang-tools"
  "${MINGW_PACKAGE_PREFIX}-libgpr"
  "${MINGW_PACKAGE_PREFIX}-libvss"
  "${MINGW_PACKAGE_PREFIX}-xmlada"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gprbuild"
)
source=("https://github.com/AdaCore/lal-refactor/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('10cdb2f308eccce1ca3493e10e3379718920999569637505b339d3a6dd0b7b01')

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  BUILD_MODE=prod \
  LIBRARY_TYPE=relocatable \
  make lib bin
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}

  BUILD_MODE=prod \
  LIBRARY_TYPE=relocatable \
  make install PREFIX=${pkgdir}${MINGW_PREFIX}

  install -Dm644 -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}" \
    "${srcdir}/${_realname}-${pkgver}/LICENSE.txt"
}
